import { fileURLToPath, URL } from "node:url";

import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import vueDevTools from "vite-plugin-vue-devtools";

// https://vite.dev/config/
export default defineConfig({
  plugins: [vue(), vueDevTools()],
  resolve: {
    alias: {
      "@": fileURLToPath(new URL("./src", import.meta.url)),
    },
  },
  // 服务相关
  server: {
    // 允许IP访问
    host: "0.0.0.0",
    // 应用端口 (默认:8080)
    port: 8080,
    // 运行是否自动打开浏览器
    open: true,
    // 代理配置
    proxy: {
      "/api": {
        secure: false,
        changeOrigin: true,
        target: "https://stageadmin.aimuspal.com",
        rewrite: (path) => path.replace(/^\/api/, ""),
      },
    },
  },
});
